<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="shortcut icon" href="<%= controller.request.relative_url_root -%>/favicon.ico" />
  <title><%= CUSTOM_RITERAL[:abbr_app_title] -%> - <%= @title -%></title>
<script language="JavaScript" type="text/javascript"><!--
var relative_url_root = '<%= controller.request.relative_url_root -%>';
//--></script>
  <%= skip_stylesheet_link_tag "style" -%>
  <%= stylesheet_link_tag "style" -%>
  <%= stylesheet_link_tag "skins-base" -%>
  <%= stylesheet_link_tag("skins/#{session[:user_custom_theme]}/skin.css") -%>
  <%= stylesheet_link_tag controller.controller_name -%>
  <%= skip_stylesheet_link_tag 'nyroModal.full.css' %>
  <%= skip_stylesheet_link_tag 'jquery.autocomplete.css' %>

  <%= skip_javascript_include_tag 'prototype' %>
  <%= skip_javascript_include_tag 'jquery.js' %>
  <%= skip_javascript_include_tag 'jquery.color.js' %>
  <script language="JavaScript" type="text/javascript">$j = jQuery.noConflict();</script>
  <%= skip_javascript_include_tag 'scriptaculous' %>
  <%= skip_javascript_include_tag 'ufo' %>
  <%= javascript_include_tag 'application' %>
  <%= skip_javascript_include_tag 'skip_util' %>

  <%= skip_javascript_include_tag "jquery.nyroModal.js" %>
  <%= skip_javascript_include_tag "jquery.bgiframe.min.js" %>
  <%= skip_javascript_include_tag "jquery.dimensions.js" %>
  <%= skip_javascript_include_tag "jquery.autocomplete.js" %>
  <%= skip_javascript_include_tag "jquery.jTagging.js" %>

<script language="JavaScript" type="text/javascript">
<!--
function imageSizing(){
  var imgs = document.getElementsByName("picture");
  if(!imgs) return;
  for(i=0; i<imgs.length; i++){
    width = imgs[i].width;
    height = imgs[i].height;
    fitImageSize(imgs[i], width, height);
  }
}
Event.observe(window, 'load', function() {
  imageSizing();
  fnLoadPngs();
} , false);
//-->
</script>
</head>

<body>
<script type='text/javascript'></script>
<div id="header">
  <div id="logo" style="align: top; margin: 3px 0 0 20px;"><%= link_to(image_tag('/custom/images/top_logo.png', :alt => CUSTOM_RITERAL[:abbr_app_title], :height => "45"), :controller => 'mypage', :action => 'index')  %></div>
  <%= skip_menu_link -%>
  <%= render :partial => "shared/full_text_search" if FULL_TEXT_SEARCH_SETTING -%>
</div><!-- header -->

<div id="top">
  <div id="menu_btn">
<% MENU_BTNS.each do |btn| -%>
<%= btn[:separator] ? "| " : link_to(icon_tag(btn[:img_name], {:alt=>btn[:name], :title=>btn[:name]}), btn[:url]) -%>
<% end -%>
  </div>
  <div id="user_ctl">
    <a href="<%= CUSTOM_RITERAL[:help_url] -%>" target="_blank"><span id="link_help">ヘルプ</span></a>
  </div>
  <div id="select_my_group" style="margin-top: 5px; display: none;"></div>
</div>

<div id="main">

<div id="side">
  <ul id="main_menu">
<% MENU_BTNS.each do |btn| -%>
  <% if btn[:separator] -%>
  <li class="separator"><%= btn[:name] -%></li>
  <% elsif @main_menu == btn[:name] -%>
  <li class="selected"><%= link_to icon_tag(btn[:img_name], {:alt=>btn[:name], :title=>btn[:name]}) + btn[:name], btn[:url] -%></li>
  <% else -%>
  <li class="normal"><%= link_to icon_tag(btn[:img_name], {:alt=>btn[:name], :title=>btn[:name]}) + btn[:name], btn[:url] -%></li>
  <% end -%>
<% end -%>
  </ul>
</div><!-- side -->

<div id="panel">
  <div style="_width: 98%;">
    <h1 id="title"><%=h @title %></h1>
    <% if @tab_menu_source -%>
    <div id="tab_menu"><%= generate_tab_menu(@tab_menu_source, @tab_menu_option) %></div>
    <br style="clear: left;" />
    <% end -%>
  </div>

  <div id="tab_body">
    <% if flash[:warning] != nil %>
    <div class="warning" onclick="this.style.display = 'none';">
      <h3 style="width: 100%;"><%= flash[:warning] %></h3><span>[クリックでメッセージ消去]</span>
    </div>
    <% end %>
    <% if flash[:notice] != nil %>
    <div class="notice" onclick="this.style.display = 'none';">
      <h3 style="width: 100%;"><%= flash[:notice] %></h3><span>[クリックでメッセージ消去]</span>
    </div>
    <% end %>
    <%= @content_for_layout %>
  </div><!-- tab_body -->
</div><!-- panel -->

<div style="clear: both;"><br/></div>

</div><!-- main -->

</body>
</html>
<script type="text/javascript">
<%# FIXME 以下のclickMyItemsメソッドを利用すれば、他アプリのclick_my_itemsを使っている箇所を置き換え可能 %>
$j(function(){
    var clickMyItems = function(actionUrl, updateId, linkUrlBase, _options) {
        // ajaxUpdate対象の要素が空じゃない（つまり2回目以降の場合はtoggleするだけ)
        if (!$j(updateId).is(':empty')) {
            $j(updateId).toggle();
            return;
        }
        // ajaxLoad中のインジケータ表示
        $j(updateId).append('<img src="' + platform_url_root + '/images/skip/indicator.gif" />');
        $j(updateId).show();

        // ajaxLoad(jsonデータ取得)
        $j.getJSON(actionUrl, function(items) {
            // request完了後一旦ajaxUpdate対象の要素をクリアしておく(以下の処理で要素が空かどうかで判断するため)
            $j(updateId).empty();
            $j.each(items, function(itemId, val) {
                // ajaxUpdate対象の要素が空(つまりループの最初のみテキストを追加)
                $j(updateId + ':empty').append(document.createTextNode(_options.result_message));
                var url = relative_url_root + linkUrlBase + itemId;
                $j(updateId)
                .append(
                    $j('<a href="' + url + '"></a>')
                    .append(document.createTextNode('[' + val + ']'))
                    .css('marginRight', '5px')
                );
            });
            // ajaxUpdate対象の要素が空(つまり表示するものがない場合のテキスト追加)
            $j(updateId + ':empty').append(document.createTextNode(_options.nothing_message));
            // 区切り線を追加
            $j(updateId).prepend($j('<div>').css({ borderTop : '1px dashed silver', marginTop : '3px' }));
        });
    };

    $j('#my_group_link')
    .click(function() {
        clickMyItems('<%= url_for(:controller => 'mypage', :action => 'ado_my_groups') -%>', '#select_my_group', '/group/',
            { nothing_message: '表示するグループがありません', result_message: 'グループ選択：' });
        return false;
    });
});
</script>
